package com.mdd.admin.controller.yylq;

import com.mdd.admin.aop.Log;
import com.mdd.admin.service.yylq.ITAppEnterpriseQualificationRecordService;
import com.mdd.admin.validate.commons.IdValidate;
import com.mdd.admin.validate.commons.PageValidate;
import com.mdd.admin.validate.yylq.TAppEnterpriseQualificationRecordCreateValidate;
import com.mdd.admin.validate.yylq.TAppEnterpriseQualificationRecordSearchValidate;
import com.mdd.admin.validate.yylq.TAppEnterpriseQualificationRecordUpdateValidate;
import com.mdd.admin.vo.yylq.TAppEnterpriseQualificationRecordDetailVo;
import com.mdd.admin.vo.yylq.TAppEnterpriseQualificationRecordListedVo;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.validator.annotation.IDMust;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/adminapi/yylq/appEnterpriseQualificationRecord")
@Api(tags = "羊羊领企---企业资质申请记录管理")
public class TAppEnterpriseQualificationRecordController {

    @Resource
    ITAppEnterpriseQualificationRecordService iTAppEnterpriseQualificationRecordService;

    @GetMapping("/list")
    @ApiOperation(value="企业资质申请记录列表")
    public AjaxResult<PageResult<TAppEnterpriseQualificationRecordListedVo>> list(@Validated PageValidate pageValidate,
                                                                                  @Validated TAppEnterpriseQualificationRecordSearchValidate searchValidate) {
        PageResult<TAppEnterpriseQualificationRecordListedVo> list = iTAppEnterpriseQualificationRecordService.list(pageValidate, searchValidate);
        return AjaxResult.success(list);
    }

    @GetMapping("/detail")
    @ApiOperation(value="企业资质申请记录详情")
    public AjaxResult<TAppEnterpriseQualificationRecordDetailVo> detail(@Validated @IDMust() @RequestParam("id") Integer id) {
        TAppEnterpriseQualificationRecordDetailVo detail = iTAppEnterpriseQualificationRecordService.detail(id);
        return AjaxResult.success(detail);
    }

    @Log(title = "企业资质申请记录新增")
    @PostMapping("/add")
    @ApiOperation(value="企业资质申请记录新增")
    public AjaxResult<Object> add(@Validated @RequestBody TAppEnterpriseQualificationRecordCreateValidate createValidate) {
        iTAppEnterpriseQualificationRecordService.add(createValidate);
        return AjaxResult.success();
    }

    @Log(title = "企业资质申请记录编辑")
    @PostMapping("/edit")
    @ApiOperation(value="企业资质申请记录编辑")
    public AjaxResult<Object> edit(@Validated @RequestBody TAppEnterpriseQualificationRecordUpdateValidate updateValidate) {
        iTAppEnterpriseQualificationRecordService.edit(updateValidate);
        return AjaxResult.success();
    }

    @Log(title = "企业资质申请记录删除")
    @PostMapping("/del")
    @ApiOperation(value="企业资质申请记录删除")
    public AjaxResult<Object> del(@Validated @RequestBody IdValidate idValidate) {
        iTAppEnterpriseQualificationRecordService.del(idValidate.getId());
        return AjaxResult.success();
    }

}
